package com.zyy.smartcity1129.work;

import android.view.View;
import android.widget.FrameLayout;

import androidx.fragment.app.Fragment;
import androidx.lifecycle.MutableLiveData;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.zyy.smartcity1129.BaseFragment;
import com.zyy.smartcity1129.MainActivity;
import com.zyy.smartcity1129.R;
import com.zyy.smartcity1129.util.Http;

/**
 * @ClassName: WorkFragment$
 * @Description: 作用
 * @Author: letquit
 * @CreateDate: 6/12/2021$
 * @Version: 1.0
 */
public class WorkFragment extends BaseFragment {
    private FrameLayout fragmentMovie;
    public static BottomNavigationView bottomMovie;

    @Override
    protected int layId() {
        return R.layout.f_work;
    }

    @Override
    protected String title() {
        return "找工作";
    }

    @Override
    protected boolean back() {
        return true;
    }

    @Override
    protected Boolean bottom() {
        return true;
    }

    public static MutableLiveData<String> mutableLiveData = new MutableLiveData<>();

    @Override
    protected void init(View iv) {
        initView(iv);
        Http.base="http://124.93.196.45:10001";
        Http.token= MainActivity.mToken;
        mutableLiveData.observe(getViewLifecycleOwner(), s -> {
            title.setText(s);
        });
        getActivity().getSupportFragmentManager().beginTransaction().add(R.id.fragmentMovie, new LookJobFragment()).commit();
        bottomMovie.setOnNavigationItemSelectedListener(item -> {
            switch (item.getItemId()) {
                case R.id.workLookJob:
                    add(new LookJobFragment());
                    break;
                case R.id.workDeliveryRecord:
                    add(new DeliveryRecordFragment());
                    break;
                case R.id.workResume:
                    add(new ResumeFragment());
                    break;
            }
            return true;
        });
    }

    public void add(Fragment fragment) {
        getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragmentMovie, fragment).commit();
    }

    private void initView(View iv) {
        fragmentMovie = (FrameLayout) iv.findViewById(R.id.fragmentMovie);
        bottomMovie = (BottomNavigationView) iv.findViewById(R.id.bottomMovie);
    }
}
